package org.monitoringtools.managedbeans.impl;

import org.monitoringtools.managedbeans.Monitoring;
import org.monitoringtools.manager.MonitorManager;

public class MonitoringMBean implements Monitoring {

    private final MonitorManager manager = new MonitorManager("Core", "DataSource", "Front-End");

    @Override
    public long failureByMonitor(String id) {
        return manager.failure(id);
    }

    @Override
    public long failureByMonitor(String id, String timeUnit) {
        return manager.getMonitor(id).getCounter(timeUnit).failure();
    }

    @Override
    public void reset() {
        manager.reset();
    }

    @Override
    public long successByMonitor(String id) {
        return manager.success(id);
    }

    @Override
    public long successByMonitor(String id, String timeUnit) {
        return manager.getMonitor(id).getCounter(timeUnit).success();
    }

    @Override
    public long totalByMonitor(String id) {
        return manager.total(id);
    }

    @Override
    public long totalByMonitor(String id, String timeUnit) {
        return manager.getMonitor(id).getCounter(timeUnit).total();
    }
}